from flask import Blueprint,render_template,request

ac = Blueprint('ac',__name__)
import pymysql
conn = pymysql.connect(#连接数据库驱动
    host='127.0.0.1',
    user='root',
    password='123456',
    db='orderingsystem',
    charset='utf8'
)
@ac.route('/')
def login():
    return render_template('login.html')

# @ac.route('/login')
# def getLoginRequest():#登录管理
#     user = request.args.get('userName')
#     pwd = request.args.get('password')
#     cursor = conn.cursor()
#     # SQL 查询语句
#     sql = "select * from user where user_name='" + user + "' and pwd='" + pwd + "'"#根据输入的账号密码查询数据库
#     try:
#         # 执行sql语句
#         cursor.execute(sql)
#         results = cursor.fetchall()
#         if len(results) == 1:#查询到存在该用户跳转到index.html
#             return render_template('index.html')
#         else:
#             return '用户名或密码不正确'
#         # 提交到数据库执行
#         conn.commit()
#     except:
#         # 如果发生错误则回滚
#         traceback.print_exc()
#         conn.rollback()
#     # 关闭数据库连接
#     conn.close()


